/* $Id: chat_server.h jjs $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

class chatserver {
  private:
    std::map<std::string, member> members; ///< member record on member name
    std::map<std::string, world> worlds; ///< worlds on world name
    int c_time; ///< current time
    member *c_member; ///< current selected member
    world *c_world; ///< current selected world
    room *c_room; ///< current selected room
    channel *c_channel; ///< current communication channel
    std::map<std::string, sigc::signal<void, std::string> > commands; ///< Commands and the handler
    communicate comm; ///< Client connection
    communicate cent_comm; ///< Central server connection
    channel *cent_ch; ///< Communication channel to the central server to check session id's
    std::string central_server; ///< Ip address of the central server
    std::string session; ///< Session string for commuication to the central server
  public:
    chatserver();
    ~chatserver();
    void leadership_check(room *r); ///< check if a channel still has an connected leader
    void cleanup(world *w, std::string user); ///< remove this user quit last room
    void change_password(std::string text); ///< change the password on the room
    void join_channel(std::string channelname); ///< join a room
    void message(std::string text); ///< send a message to a room
    void list_channels(std::string dummy); ///< ask for a list of rooms
    void channel_info(std::string channel); ///< get full information on a room
    void title_channel(std::string title); ///< change the title of a room
    void quit(std::string message); ///< leave the world
    void channel_type(std::string type); ///< set the join type of a room
    void invite(std::string name); ///< invite someone to your room
    void whisper(std::string player); ///< send a private message to a member
    void leave(std::string channel); ///< leave a room
    void ignore(std::string player); ///< ignore a specific player
    void unignore(std::string player); ///< show messages from a specific player again
    void kick(std::string player); ///< kick a member from the room
    void mod(std::string player); ///< give a member moderation rights
    void unmod(std::string player); ///< remove moderation rights
    void mute(std::string player); ///< remove speech from a specific member
    void voice(std::string player); ///< add speech again of a specific member
    void silence(std::string text); ///< remove speech from all non moderators
    void unsilence(std::string text); ///< allow speech from non moderators
    void whispers(std::string dummy); ///< allow whispers
    void nowhispers(std::string text); ///< deny whispers
    void answer(std::string text); ///< automatic answer to all whispers
    void crown(std::string player); ///< make another member room leader
    void handler(channel *ch); ///< routine to handle messages and commands from players
    void client_handler(channel *ch); ///< routines to handle communication with the central server
    void ip_addr(std::string host); ///< set the ip address of the central server
    void session_set(std::string session); ///< set the session id with the central server
    void set_name(std::string n); ///< set the name of the chatserver on the central server
    void log_level(std::string level);
    void log_file(std::string logfile);
    void do_fork(std::string file); ///< fork this task to the background
    void main_loop(); ///< main connunication loop
};
